using System.Collections;
using UnityEngine;
using UnityEngine.Rendering;

public class Enemy_罐子1 : MonoBehaviour, IBeAttack
{
	public int _EnemyInSceneID = -1;

	private string _EnemyStrID;

	private GameObject _GO_灵蕴;

	private Animator _Ani;

	private Collider2D _Co2D;

	public AudioClip _AudioC_打碎罐子;

	public AudioClip _AudioC_收集灵韵;

	public int _阵营
	{
		get
		{
			return 2;
		}
		set
		{
			Debug.LogError("？？？？？");
		}
	}

	public Vector2 _BeAttack_Pos { get; set; }

	public float _BeAttack_击退力度 { get; set; }

	private void Awake()
	{
		if (_EnemyInSceneID >= 0)
		{
			_EnemyStrID = $"罐子-{MonoSingleton<MySceneManager>.Instance.F_GetCurrSceneID()}-{_EnemyInSceneID}";
			if (!MonoSingleton<GameManager>.Instance.F_EnemyCanInit(_EnemyStrID))
			{
				base.gameObject.SetActive(value: false);
			}
		}
	}

	private void Start()
	{
		_Ani = GetComponent<Animator>();
		_GO_灵蕴 = base.transform.Find("C_灵蕴").gameObject;
		_Co2D = GetComponent<Collider2D>();
        int y = (int)(Mathf.Abs((gameObject.transform.position.y - 10) * 5));
        GetComponent<SortingGroup>().sortingOrder = y;

    }

	public void BeAttack(float atk_生命, float atk_僵直, float atk_击退力度, Vector2 atk_Pos, bool atk_Is远程 = false)
	{
		_Co2D.enabled = false;
		StartCoroutine(Cor_破碎());
	}

	private IEnumerator Cor_破碎()
	{
		_Ani.Play("破碎");
		MonoSingleton<AudioManager>.Instance.F_Play_SFX(_AudioC_打碎罐子);
		MonoSingleton<GameManager>.Instance.F_EnemyDie(_EnemyStrID);
		yield return new WaitForSeconds(0.1f);
		if (Random.value < 0.4f)
		{
			_GO_灵蕴.SetActive(value: true);
			MonoSingleton<AudioManager>.Instance.F_Play_SFX(_AudioC_收集灵韵);
			MonoSingleton<GameManager>.Instance.F_获得经验(5f);
		}
		yield return new WaitForSeconds(3f);
		Object.Destroy(base.gameObject);
	}
}
